import request from '@/utils/request'
import defaultSettings from '@/settings'

export const apiUrlConfig = {
  queryUrl: `${defaultSettings.ctx.authorityApp}/s/userInfo/search`,
  exportUrl: `${defaultSettings.ctx.authorityApp}/s/userInfo/search`,
  delUrl: `${defaultSettings.ctx.authorityApp}/s/userInfo/remove`,
  templateUrl: `${defaultSettings.ctx.authorityApp}/s/userInfo/exportUserLineTemplate`,
  importUrl: `${defaultSettings.ctx.authorityApp}/s/userInfo/importUserFile`,
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/selectUserById?id=`+userId,
    method: 'get'
  })
}

// 查询用户详细 包含扩展参数
export function getUserAndExtend(userId) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/selectUserAndExpandValueById?id=`+userId,
    method: 'get'
  })
}

// 新增用户
// export function addUser(data) {
//   return request({
//     headers: {
//       'Content-Type' : 'application/json'
//     },
//     url: `${defaultSettings.ctx.authorityApp}/s/userInfo/add`,
//     method: 'post',
//     data: data
//   })
// }
// 新增用户
export function addUser(data) {
  return request({
    headers: {
      'Content-Type' : 'application/json'
    },
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/add`,
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    headers: {
      'Content-Type' : 'application/json'
    },
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/edit`,
    method: 'put',
    data: {userDtoList: data}
  })
}

// 删除用户
export function delUser(ids) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/remove?ids=` + ids,
    method: 'delete'
  })
}

// 导出用户
export function exportUser(query) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/export`,
    method: 'get',
    params: query
  })
}

// 用户密码重置
export function resetUserPwd(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/resetPwd`,
    method: 'put',
    data: data
  })
}

// 校验登录名称
export function checkLoginName(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/checkLoginNameUnique`,
    method: 'get',
    params:data
  })
}

// 校验邮箱
export function checkEmail(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/checkEmailUnique`,
    method: 'get',
    params: data
  })
}

// 校验手机号
export function checkPhone(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/checkPhoneUnique`,
    method: 'get',
    params:data
  })
}

// 用户状态修改
export function changeUserStatus(id, status) {
  const data = {
    id,
    status
  }
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/userInfo/changeStatus`,
    method: 'put',
    data: data
  })
}
